package com.lhk.appframework.presenter.splash;

import java.util.Timer;
import java.util.TimerTask;

import android.content.Context;
import android.media.TimedText;

import com.lhk.appframework.MyApplication;
import com.lhk.appframework.engine.splash.EngineSplash;
import com.lhk.appframework.presenter.BasePresenter;
import com.lhk.appframework.ui.activity.GuidActivity;
import com.lhk.appframework.ui.activity.HomeActivity;
import com.lhk.appframework.utils.UtilsTimer;
import com.lhk.appframework.utils.ui.UtilsUI;

public class ImplPresenterSplash extends BasePresenter implements PresenterSplash{
	private Context context;
	private PresenterSplashUI presenterUI;
	
	private EngineSplash engineSplash;
	
	public ImplPresenterSplash(Context context, PresenterSplashUI presenterUI) {
		super();
		this.context = context;
		this.presenterUI = presenterUI;
	}

	@Override
	public void work() {
		engineSplash = MyApplication.getInstance().getFactoryEngine().createEngineSplash(context);
		
		int showWhichUI = engineSplash.getSplahGo2TypeUI(context);
		if(showWhichUI == EngineSplash.TYPEUI_GUIDED){
			go2GuidedUI();
		}else if(showWhichUI == EngineSplash.TYPEUI_ADVERTISEMENT){
			showAdvertisementUI();
		}else{
			showLogoUI();
		}
		
		
	}
	
	
	private void go2GuidedUI(){
		UtilsUI.go2Activity(context, GuidActivity.class);
		presenterUI.finishUI();
	}
	
	
	private void showLogoUI(){
		presenterUI.showLogoUI();
		UtilsTimer.schedule(new TimerTask() {
			@Override
			public void run() {
				UtilsUI.go2Activity(context, HomeActivity.class);
				presenterUI.finishUI();
			}
		}, 2000);
		
		
	}
	
	
	private void showAdvertisementUI(){
		
	}
	
	
	
	
}
